home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
harderr.zip
/
TIMEBOOT.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-08-31
|
8KB
|
206 lines
; Program Name : timeboot.asm
; Author : bill buckels
; Date : Sept 1, 1991
; Function : tsr program to reboot an IBM PC if a keypress
; does not occur within the time limit in minutes
; as specified on the command line.
; if the entry is not in the range of 1-9
; a default of 5 minutes is assumed.
; it is meant to be used during interactive
; periods only... potential for damage exists.
cr equ 0dh ;carriage return
lf equ 0ah ;line feed
CODE SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CODE
ORG 100h
BEGIN: jmp INITIALIZE ;jump to initialization code
old_int_9h label dword ;old keyboard interrupt vector
old_keyboard_int dw 2 dup (?)
old_int_1ch label dword ;old timer interrupt vector
old_timer_int dw 2 dup (?)
target dw 1092 ; 1092 ticks per minute
timecheck dw 0 ; counter is set to zero
minutes db 5 ; default multiplier is 5 minutes
REBOOT: ;INTEL 8088 machine language instructions
;to duplicate the ctrl-alt-del key combo
;and reboot the machine.
DB 0B8h, 040h, 000h ;mov ax, 0040h
DB 050h, 007h ;push ax
DB 026h, 0C7h ;pop es
DB 006h, 072h, 000h, 034h, 012h ;mov word ptr [0072h], 1234h
DB 0EAh, 000h, 000h, 0FFh, 0FFh ;jmp 0ffffh:0000h
;-------------------------------------------------------
;Resident mainline and Front-end routine for the timer
;interrupt handler. Execution is vectored here 18.2 ticks
;per second and a counter is incremented.
;If the counter reaches the target the computer reboots.
;-------------------------------------------------------
TIMERTICK PROC NEAR
sti ;enable interrupts
push ax ;save registers
push bx
push cx
push dx
push si
push di
push ds
push es
inc timecheck ;increment the timecheck
mov ax,timecheck
mov bx,target ;compare the counter to the target
cmp bx,ax
jbe REBOOT ;reboot the machine if time is up
pop es ;otherwise restore the registers
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
jmp old_int_1ch ;goto BIOS timertick routine
TIMERTICK ENDP
;-------------------------------------------------------
;Resident mainline and Front-end routine for the keyboard
;interrupt handler. Execution is vectored here whenever
;an interrupt 9 is generated by the keyboard.
;Each time a key is pressed a counter is reset to 0.
;-------------------------------------------------------
KEYPRESS PROC NEAR
sti ;enable interrupts
push ax ;save registers
push bx
push cx
push dx
push si
push di
push ds
push es
mov timecheck,0 ;set the timer check to zero
pop es ;restore registers
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
jmp old_int_9h ;goto BIOS keyboard routine
KEYPRESS ENDP
;------------------------------------------------------------
; RESIDENT PORTION ENDS *** TRANSIENT PORTION STARTS
;------------------------------------------------------------
;------------------------------------------------------------
;initialization message - the requested time limit is inserted here
;------------------------------------------------------------
TITLE1$ db '╔═════════════════════════════════════════╗',cr,lf
db '║ TIMEBOOT(C) by Bill Buckels 1991 ║',cr,lf
db '║ USAGE is : "TIMEBOOT [minutes 1-9]" ║',cr,lf
db '║ DEFAULT is : "TIMEBOOT 5" ║',cr,lf
db '╚═════════════════════════════════════════╝',cr,lf
db 'This Computer Will REBOOT If A Key Is Not Pressed For ','$'
TITLE2$ db '5 MINUTES.',cr,lf,'$'
;------------------------------------------------------------
;LIST$ writes a string to stdout
;------------------------------------------------------------
LIST$ PROC NEAR
push ax
mov ah,9h ; call dos function 9H
int 21h
pop ax
ret
LIST$ ENDP
;----------------------------------------------------------------
;INITIALIZE performs tasks to set the stage for the resident part
;of the program.
;-----------------------------------------------------------------
INITIALIZE PROC NEAR
;let them know who we are
lea dx, TITLE1$
call LIST$
; get command line arg from psp:82h
MOV BX,82h ; point at first character in arg
MOV DL,BYTE PTR[BX] ; and move it into dl
SUB DL, '0' ; change from ascii to numeric
CMP DL, 1 ; is it below 1
JB SKIPIT ; if so skipit
CMP DL, 9 ; is it above 9
JA SKIPIT ; if so skipit
MOV minutes,DL ; change the muliplier if in range
ADD DL, '0' ; make it ascii again and
MOV TITLE2$, DL ; update the string with the new time
SKIPIT: LEA DX,TITLE2$
CALL LIST$ ;print the confirmation of the time
MOV AX,target
SUB DX,DX ;build the target time in clock ticks
MOV DL,minutes
IMUL DX
MOV target, AX
;Now save the keyboard vector and replace it
;with one pointing to the
;code that we will leave behind in memory.
mov ah,35h ;get current interrupt 9 vector
mov al,9
int 21h
mov old_keyboard_int,bx ;save vector offset
mov old_keyboard_int[2],es ;save vector segment
mov ah,25h ;set new vector
mov al,9
lea dx,KEYPRESS ;point it to new handler
int 21h
;Now save the timer vector and replace it
;with one pointing to the
;code that we will leave behind in memory.
mov ah,35h ;get current interrupt 1C vector
mov al,1ch
int 21h
mov old_timer_int,bx ;save vector offset
mov old_timer_int[2],es ;save vector segment
mov ah,25h ;set new vector
mov al,1ch
lea dx,TIMERTICK ;point it to new handler
int 21h
;Exit thru INT 27h and reserve enough room
;the offset of TITLE1$ is a marker to end of resident code
mov dx,offset TITLE1$ ;reserve space for code
int 27h ;terminate-but-stay-resident
INITIALIZE ENDP
;
CODE ENDS
END BEGIN